Skip to content

Stop MCP authorization recovery from looping reconnects - #857

Merged
TheGreatAxios merged 10 commits into
mainfrom
cl-7528-fix-mcp-linear-server-disconnect-and-reconnect-loop
Sep 10, 2026
Merged

Stop MCP authorization recovery from looping reconnects#857
TheGreatAxios merged 10 commits into
mainfrom
cl-7528-fix-mcp-linear-server-disconnect-and-reconnect-loop

Conversation

@TheGreatAxios

Copy link
Copy Markdown
Collaborator

Summary

  • Refresh tokens before browser re-auth, and cap browser prompts at three per server with a five-minute cooldown
  • Coordinate one recovery episode per connection: first PKCE verifier wins, the prompt cap and onAuthorized fire only after the retried call succeeds, and close() aborts in-flight OAuth even when connect supplied an external signal
  • Failed re-auth surfaces a stable error instead of looping reconnects

Verification

  • bun test on the four MCP auth files: 39 pass, 0 fail
  • bun run typecheck exits 0
  • bun run build exits 0
  • bun run check:projects-dir-guard exits 0
  • ESLint error on Promise.withResolvers<void>() in src/mcp/client.ts is fixed

Fixes CL-7528

@linear-code

linear-code Bot commented Sep 9, 2026

Copy link
Copy Markdown

CL-7528

@TheGreatAxios TheGreatAxios left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: approve (GitHub cannot approve own PR).

CL-7528 holds at 315f2c0. Recovery is coordinated per connection: refresh before browser, 3-prompt cap with cooldown, first PKCE verifier wins, onAuthorized and cap-clear only after verified recovery, close() aborts OAuth via lifecycle, abort during refresh does not emit a browser prompt, and a later recovery generation cannot steal a prior episode notify.

Focused MCP auth tests: 43 pass, 0 fail. bun run typecheck exit 0. ESLint on touched files: 0 errors.

No blocking findings remaining from the in-session review loop.

Linear MCP servers periodically disconnect and every auth failure fell
through to a browser re-auth prompt. The provider now performs a
refresh_token grant against discovered authorization server metadata
before any browser flow, and browser prompts are capped at three per
server with a five minute cooldown, surfacing a clear error through the
connect failure path instead of looping forever.
@TheGreatAxios
TheGreatAxios force-pushed the cl-7528-fix-mcp-linear-server-disconnect-and-reconnect-loop branch from 28de297 to ff2bea7 Compare September 10, 2026 02:12
@TheGreatAxios

Copy link
Copy Markdown
Collaborator Author

Follow-up: client.close() after verified recovery, while the retried tool call is still in flight, now fires onAuthorized and clears the browser-auth cap so a reconnect does not inherit a spent prompt.

HEAD a31c01c5. CI green.

Reconnect during an in-flight browser wait was starting a new coordinator
and prompting again. An ignored tab left connect pending until abort.
@TheGreatAxios
TheGreatAxios merged commit c701aff into main Sep 10, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant